package cn.edu.sgu.www.mhxysy.controller.system;

import cn.edu.sgu.www.mhxysy.consts.CustomConstants;
import cn.edu.sgu.www.mhxysy.consts.CustomMessages;
import cn.edu.sgu.www.mhxysy.consts.MimeTypes;
import cn.edu.sgu.www.mhxysy.restful.JsonResult;
import cn.edu.sgu.www.mhxysy.service.system.PermissionService;
import com.github.xiaoymin.knife4j.annotations.ApiSupport;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author 沐雨橙风ιε
 * @version 1.0
 */
@Api(tags = "权限管理")
@ApiSupport(author = CustomConstants.AUTHOR)
@RestController
@RequestMapping(path = "/permission", produces = MimeTypes.APPLICATION_JSON_CHARSET_UTF_8)
public class PermissionController {

    private final PermissionService permissionService;

    @Autowired
    public PermissionController(PermissionService permissionService) {
        this.permissionService = permissionService;
    }

    @ApiOperation("初始化权限列表")
    @RequestMapping(value = "/resources", method = RequestMethod.POST)
    public JsonResult<Void> resources() throws ClassNotFoundException {
        permissionService.resources();

        return JsonResult.success(CustomMessages.OPERATE_SUCCESS);
    }

}